
; Explosion Class
; ties together damage, destruction and animation

(load "damage.scm")
(load "destruction.scm")
(load "sprite.scm")

(define explosion%
  (class damage%
    
    ; PHYSICS-OBJECT%
    (inherit-field position
                   size)
    ; PUBLIC VARIABLES
    (init-field [magnitude 1])
    ; PRIVATE VARIABLES
    
    ; Constructor/Initialization
    (super-new [solid #f] [affected-by-gravity #f])
    (let* ([sprite       (new sprite%      [position position] [sprite-name (string-append "explosion" (number->string magnitude))])]
           [destruction  (new destruction% [position position] [size (send sprite get-size)])])
      ; set damage size
      (set! size (send sprite get-size))
      ; add created objects to world
      (for-each (lambda (object)
                  (send *world* add-object object))
                (list sprite destruction)))))

